﻿<%@ Page language="c#" Codebehind="Transaction.aspx.cs" AutoEventWireup="false" Inherits="zsproject.page.Transaction" %> 
<%@ Import Namespace="eap.share" %>
<%@ Import Namespace="zsproject.page" %>
<%@ Import Namespace="zsproject.admin" %>
<%
	//---------------------------------------------------------------//
	string page=Req.getPara(Request,"page");
	string mainPage=Sys.fieldGet(page,1,"_");
	string actionPage=Sys.fieldGet(page,1,"_")+"_action";
	string SCRIPT_NAME=AdminLib.getSimpleRequestURL(Request);
	AdminUser user = (AdminUser)Session["_user"];

	string actlist=(string)output["actlist"];
	int pageRowNum = 20;
	int pageNum = 1;
	if(Req.getPara(Request,"n") != "")
	{
	  pageNum = Convert.ToInt32(Req.getPara(Request,"n").Trim());
	  pageRowNum = Convert.ToInt32(((AdminUser)Session["_user"])["cfg_list"]);      
	}
	//---------------------------------------------------------------//

	string t=Req.getPara(Request,"t");
	string WEB_PAGE =Request.Url.ToString().Replace("&",",");
	string l=Req.getPara(Request,"l");
	string p=Req.getPara(Request,"p");
	string a=Req.getPara(Request,"a"); 
	string tt=Req.getPara(Request,"tt"); 
	string group_id=Req.getPara(Request,"group_id"); 
	//查询属于下属
	if(group_id=="")
	{
		//查询所有管辖区域的企业
		group_id= user["dept_id"];
	}
	
	string method=Req.getPara(Request,"method");
	string method_name=Req.getPara(Request,"method_name");
%>
<html>
<head>
<title><%=AdminLib.STR_TITLE%></title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
<meta http-equiv='Content-Type' content='text/html; charset=gbk'>
<link rel='stylesheet' href='<%=user.getSkinPath()%>css/eap.css'>
<script language='javascript' src='..<%=AdminLib.EAP_PATH%>/eap.js'></script>
<link rel='stylesheet' href='../skin/zsproject.css'>
<script language='javascript' src='../skin/zsproject.js'></script>
<script charset="UTF-8" src="../tools/kindeditor-4.1.5/kindeditor.js"></script>
<script language='javascript' src="../skin/validation.js"></script>
<script language="javascript" type="text/javascript" src="../tools/My97DatePicker/WdatePicker.js"></script>

<style type="text/css" >
.formitem{background-color: #CBCBCC;}
.formitem th{height:22px; background-color:#E0F1FB;padding-left:3px;text-align:right;}
.formitem td{padding:3px;background-color:#ffffff; line-height:20px;}
</style>

</head>
<!-------------------------------------------框架-------------------------------------->
<%if(t.IndexOf("frame")!=-1){%>
<frameset cols="180,*" frameborder="0" border="0" framespacing="0">
	<frame name="tree" src="../page/tree.aspx?page=<%=t%>&tt=<%=tt%>&l=<%=l%>&p=<%=p%>&a=<%=a%>&f=<%=WEB_PAGE.Replace(t,"")%>" frameborder=yes>
	<frame name="right" src="../page/firm.aspx?page=List&method=<%=method%>" frameborder=yes>
</frameset>
<%return;}%>
<!-------------------------------------------框架-------------------------------------->
<body class="bodyframe" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">  
<!--#INCLUDE FILE="../epass/verify.aspx"-->
 
<%//信息管理
 if(page=="List"){
   string search_title =(string)output["search_title"];
   System.Data.DataRowCollection list=(System.Data.DataRowCollection)output["list"];
   AdminList lst=(AdminList)output["lst"];
%>

<table class="linetitle" border="0" width="100%" cellspacing="0" cellpadding="1">
<tr>
   <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="pagetoobar">
         <tr  height="26">
            <td><strong>&nbsp;&nbsp;信息列表</strong></td>
            <td align="right" style="display:none"><input class="ButtonCss" onmouseover="this.className='ButtonCss_mouseover'" onmouseout="this.className='ButtonCss_mouseout'" id="btn_new" type="button" value="新增"  onclick="window.document.location.href='<%=SCRIPT_NAME%>?page=Form&method=edit';"></td>
         </tr>
      </table>
   </td>
</tr>
</table>

<table class=tbsearch border=0 width=100% cellspacing=0 cellpadding=1 style="">
<form name=frmMain method="get" action="<%=lst.getQryURL()%>"><%=lst.getQryURL2()%>
<tr><td>
关键字查询<input type=text size=30 maxlength=151 name="k" value="<%=lst.getKey()%>">
<input type=submit class="ButtonCss" onmouseover="this.className='ButtonCss_mouseover'" onmouseout="this.className='ButtonCss_mouseout'" value="查询" title="<%=search_title%>"> 
</td></tr>
</form>
</table>

<table class="tbsearch" border="0" width="100%" cellspacing="0" cellpadding="1">
	<tr>
		<td>
			<nolayer>
				<iframe name="_action" height="16" width="100%" marginwidth="0" marginheight="0" scrolling="no"
					frameborder="0" src='../admin/office.aspx?page=_action'></iframe>
			</nolayer>
		</td>
	</tr>
</table>
<script type='text/javascript'>popup_path='../admin/popup.aspx';</script>
 
<fieldset class="tfieldset" >

	<legend>
	<table width="100%" cellpadding="0" cellspacing="0">
	   <tr><td class="title"><span>&nbsp;信息列表</span></td> 
	   <td align="right"><span>
		 <input class="ButtonCss" onmouseover="this.className='ButtonCss_mouseover'" onmouseout="this.className='ButtonCss_mouseout'" id="btn_new" type="button" value="新增"  onclick="window.document.location.href='<%=SCRIPT_NAME+"?page=Form&method=edit&group_id="+group_id%>'">
		<input type=button value="删除" title="删除上述选中的记录" class="ButtonCss" onmouseover="this.className='ButtonCss_mouseover'" onmouseout="this.className='ButtonCss_mouseout'" onClick="confirmdel_var(frmg)">
	</span></td></tr>
	</table>
	</legend>

	<div id="tbl-container" style="height:340px">
		<table id="datagrid" border="0" width="100%" cellPadding=0 cellSpacing="0" bgcolor="#99ccff">
			<form  method="POST" action="<%=SCRIPT_NAME+"?page="+actionPage%>" target=_action id="frmg" name="frmg">
			<thead>
				<tr class=linetitle align=center>    
					<th><input type="checkbox" name="chkall" value="on" onClick="checkall(this.form)"  title="全选(删除)"></th>
					<th nowrap><%=lst.getOrder(user,"id","ID","序号")%></th>
					<th nowrap>操作</th>
					<!--------获取标题-------->
					<th nowrap><%=lst.getOrder(user,"title","title","标题")%></th>
					<th nowrap><%=lst.getOrder(user,"price","price","价格")%></th>
					<th nowrap><%=lst.getOrder(user,"is_change","is_change","可否用物品交换")%></th>
					<th nowrap><%=lst.getOrder(user,"contact","contact","联 系 人")%></th>
					<th nowrap><%=lst.getOrder(user,"telphone","telphone","联系电话")%></th>
					<th nowrap><%=lst.getOrder(user,"email","email","email")%></th>
					<th nowrap><%=lst.getOrder(user,"qq","qq","QQ")%></th>
					<th nowrap><%=lst.getOrder(user,"post_time","post_time","发布时间")%></th>
					<th nowrap><%=lst.getOrder(user,"state","state","状态")%></th>
				</tr>
			</thead>
			
			<tbody>	
				<%for(int index=0;list!=null&&index<list.Count;index++){
					System.Data.DataRow map=list[index];
					string id=map["id"].ToString();
				%>
				<tr align=center class=<%if(index % 2 ==1){%>datalineone<%}else{%>datalineone<%}%> onmouseover="dataline_over(this)" onmouseout="dataline_out(this)" onclick="dataline_click(this)">    
					<td nowrap width=60px><input type="checkbox" name="chk_id" id="chk_id" value="<%=map["id"]%>" title="选择(删除)"></td>
					<td nowrap width=60px><%=index+1+(pageNum-1)*pageRowNum%></td>
					<td nowrap width="60px"><input type="button" class="ButtonCss" value="编辑" onclick="window.location.href='<%=SCRIPT_NAME+"?page=Form&method="+method+"&d="+id%>'"></td>
					<!--------获取信息-------->
					<td nowrap align="center"><%=map["title"].ToString()%></td>
					<td nowrap align="center"><%=map["price"].ToString()%></td>
					<td nowrap align="center"><%=AdminLib.getKeyValue("0,否|1,是",map["is_change"].ToString())%></td>
					<td nowrap align="center"><%=map["contact"].ToString()%></td>
					<td nowrap align="center"><%=map["telphone"].ToString()%></td>
					<td nowrap align="center"><%=map["email"].ToString()%></td>
					<td nowrap align="center"><%=map["qq"].ToString()%></td>
					<td nowrap align="center"><%=map["post_time"].ToString()%></td>
					<td nowrap align="center"><%=AdminLib.getKeyValue("0,未发布|1,已发布",map["state"].ToString())%></td>
				</tr>
				<%}%>
				<tr class=lineaction style="display:none">
				<td colspan=14 align="left">
				<input type=hidden name=action value="delete">
				<input type=hidden name=d value="">
				<input type=hidden name=reload value="">
				<input type=button value="删除" title="删除上述选中的记录" class="ButtonCss" onmouseover="this.className='ButtonCss_mouseover'" onmouseout="this.className='ButtonCss_mouseout'" onClick="javascript:if(confirm_selected(this.form)){ action.value='delete'; reload.value='reload'; submit(); }">
				</td>
				</tr>
				
			</tbody>
			</form>
		</table>
	</div>
</fieldset>

<table width=100% cellspacing=0 cellpadding=1>
	<tr height=22 align=right>
		<td align="center"> <script>if(document.getElementById("dataGrid").rows.length<=2){document.write("<font color='#ff0000'>查询无结果</font>");}</script></td>
		<td><%=lst.getPageBar()%>页码<%=lst.getPageList()%></td>
	</tr>
</table>
<%}%>

<%
//新增修改页面
if(page=="Form"){
	string edit="";
	System.Data.DataRow map=(System.Data.DataRow)output["map"];
	System.Data.DataRow mapList=(System.Data.DataRow)output["mapList"];
	System.Data.DataRowCollection listAtt=(System.Data.DataRowCollection)output["listAtt"];

	string d=Req.getPara(Request,"d");
	string id=d;
	//定义除了主键以外的字段
	string province="";
	string city="";
	string counties="";
	string first_type="";
	string second_type="";
	string publication_type="";
	string transaction_type="";
	string title="";
	string price="";
	string condition="";
	string is_change="";
	string description="";
	string picture="";
	string contact="";
	string telphone="";
	string address="";
	string email="";
	string qq="";
	string post_time="";
	string state="";
	string accessory_ids="";
	string add_time="";
	string add_user="";
	if(map!=null)
	{
		//获取数据库信息
		id=map["id"].ToString();
		province=map["province"].ToString();
		city=map["city"].ToString();
		counties=map["counties"].ToString();
		first_type=map["first_type"].ToString();
		second_type=map["second_type"].ToString();
		publication_type=map["publication_type"].ToString();
		transaction_type=map["transaction_type"].ToString();
		title=map["title"].ToString();
		price=map["price"].ToString();
		condition=map["condition"].ToString();
		is_change=map["is_change"].ToString();
		description=map["description"].ToString();
		picture=map["picture"].ToString();
		contact=map["contact"].ToString();
		telphone=map["telphone"].ToString();
		address=map["address"].ToString();
		email=map["email"].ToString();
		qq=map["qq"].ToString();
		post_time=map["post_time"].ToString();
		state=map["state"].ToString();
		accessory_ids=map["accessory_ids"].ToString();
		add_time=map["add_time"].ToString();
		add_user=map["add_user"].ToString();

	}else
	{
		//新增,默认值
		state="0";
	}
%>

<table class="linetitle" border="0" width="100%" cellspacing="0" cellpadding="1">
<tr>
   <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="pagetoobar">
         <tr height="26">
            <td><strong>&nbsp;&nbsp;跳蚤市场</strong></td>
         </tr>
      </table>
   </td>
</tr>
</table>

<%=AdminLib.getIframe()%>

<table id="" class="formitem" cellspacing="1" cellpadding="0" align="center" border="0" style="background-color:#7F96BE;border-width:0px;width:100%; margin-top:5px">
<form id="frmMain"  name=frmMain method=post target="_action" enctype="multipart/form-data" action="<%=SCRIPT_NAME+"?page="+actionPage+"&d="+id%>">
	<tbody>
		<!--------获取控件--------->
		
		<tr>
			<th align="right">所在地（省）：</th>
			<td>
				<select name="province" id="province" onchange="javascript:getCity('1','scity','city','scounties','counties',this.value,'');">
					<option value="">--请选择--</option>
    				<%=ajaxRequest.getProvince("1",province)%>		
				</select>
			</td>
		</tr>
		<tr>
			<th align="right">所在地（市）：</th>
			<td>
				<span id="scity">
				<select name="city" id="city" >
				<option value="">--请选择--</option>	  	
				</select>
				</span>
			</td>
		</tr>
		<tr>
			<th align="right">所在地（县区）：</th>
			<td>
				<span id="scounties">
				<select name="counties" id="counties" >
				<option value="">--请选择--</option>	  	
				</select>
				</span>
			</td>
		</tr>
		
		
		<script>
    	function getCity(type,spanCity,cityid,spanCounties,countiesId,province,def)
		{   
			if(province!="")
			{
				var url="../admin/ajaxRequest.aspx?page=getCity&type="+type+"&cityid="+cityid+"&spanCounties="+spanCounties+"&countiesId="+countiesId+"&province="+province+"&def="+def;     
				var returnvalue=getresponseText(url+"&"+Math.random());
				
				document.getElementById(spanCity).innerHTML=returnvalue; 
				var city=document.getElementById(cityid).value;
				
				if(city=='')
				{
					document.getElementById(countiesId).value='';
				}	
			}
			else
			{
				document.getElementById(spanCity).innerHTML="<select id='"+cityid+"' name='"+cityid+"'><option value=''>--请选择--</option></select>"; 
			}		
		}

		function getCounties(type,spanCounties,countiesId,city,province,def)
		{     
			if(city!="")
			{
				var url="../admin/ajaxRequest.aspx?page=getCounties&type="+type+"&countiesId="+countiesId+"&city="+city+"&province="+province+"&def="+def;     
				var returnvalue=getresponseText(url+"&"+Math.random());
				document.getElementById(spanCounties).innerHTML=returnvalue; 		
			}
			else
			{
				document.getElementById(spanCounties).innerHTML="<select id='"+countiesId+"' name='"+countiesId+"'><option value=''>--请选择--</option></select>"; 
			}		
		}
    	</script>
    	
		<%if(province!=""){
    	%>
    	<script>
    		//修改初始化调用
    		getCity('1','scity','city','scounties','counties','<%=province%>','<%=city%>');
    		getCounties('1','scounties','counties','<%=city%>','<%=province%>','<%=counties%>');	
    	</script>
    	<%
    	}%>
		<tr>
			<th align="right">一级类别：</th>
			<td>
				
				<select name="first_type" id="first_type" onchange="javascript:getProduct('1','ssecond_type','second_type',this.value,'');">
				<option value="">--请选择--</option>
				<!--多选按钮select-->
				<%=AdminLib.getOptionSql("select id as value,product_name as title,* from t_product where product_super='0' ",first_type)%>
				</select>
			</td>
		</tr>
		<tr>
			<th align="right">二级类别：</th>
			<td>
				<span id="ssecond_type">
				<select name="second_type" id="second_type" >
				<option value="">--请选择--</option>	  	
				</select>
				</span>
			</td>
		</tr>
		
		<script>
		function getProduct(type,spanId,selectId,super_value,def)
		{     
			if(super_value!="")
			{
				var url="../admin/ajaxRequest.aspx?page=getProduct&type="+type+"&selectId="+selectId+"&super_value="+super_value+"&def="+def;     
				var returnvalue=getresponseText(url+"&"+Math.random());
				document.getElementById(spanId).innerHTML=returnvalue; 		
			}
			else
			{
				document.getElementById(spanId).innerHTML="<select id='"+selectId+"' name='"+selectId+"'><option value=''>--请选择--</option></select>"; 
			}		
		}
    	</script>
    	
    	<%if(first_type!=""){
    	%>
    	<script>
    		//修改初始化调用
    		getProduct('1','ssecond_type','second_type',<%=first_type%>,<%=second_type%>)
    	</script>
    	<%
    	}%>
		<tr>
			<th align="right">发布类型(出售,求购)：</th>
			<td>
				<select id="publication_type" name="publication_type">
				<option value="">--请选择--</option>
				<!--多选按钮select-->
				<%=AdminLib.getDictOption("transaction.publication_type",publication_type,"0")%>
				</select>
			</td>
		</tr>
		<tr>
			<th align="right"><%=transaction_type%>交易类别：</th>
			<td>
				<select id="transaction_type" name="transaction_type">
				<option value="">--请选择--</option>
				<!--多选按钮select-->
				<%=AdminLib.getDictOption("transaction.transaction_type",transaction_type,"0")%>
				</select>
			</td>
		</tr>
		<tr>
			<th align="right">标题：</th>
			<td>
				<input type="text" id="title" name="title" value="<%=title%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">价格：</th>
			<td>
				<input type="text" id="price" name="price" value="<%=price%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">新旧程度：</th>
			<td>
				<select id="condition" name="condition">
				<option value="">--请选择--</option>
				<!--多选按钮select-->
				<%=AdminLib.getDictOption("transaction.condition",condition,"0")%>
				</select>
			</td>
		</tr>
		<tr>
			<th align="right">可否用物品交换：</th>
			<td>
				<%=AdminLib.getCheckedKeyValue("0,否|1,是","is_change",is_change,"radio")%>
			</td>
		</tr>
		<tr>
			<th align="right">详细描述：</th>
			<td>
				<textarea  id="description" name="description" style="width:100%;height:100px;visibility:hidden;"><%=description%></textarea>
				<script>		
				KindEditor.ready(function(K) {
					K.create('textarea[name="description"]', {
						autoHeightMode : true,
						afterCreate : function() {
							this.loadPlugin('autoheight');
						}
					});
				});
				</script>
			</td>
		</tr>
		<tr>
			<th align="right">上传图片：</th>
			<td>
				<input type="text" id="picture" name="picture" value="<%=picture%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">联 系 人：</th>
			<td>
				<input type="text" id="contact" name="contact" value="<%=contact%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">联系电话：</th>
			<td>
				<input type="text" id="telphone" name="telphone" value="<%=telphone%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">联系地址：</th>
			<td>
				<input type="text" id="address" name="address" value="<%=address%>" <%=edit%> style="width:600px; TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">email：</th>
			<td>
				<input type="text" id="email" name="email" value="<%=email%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">QQ：</th>
			<td>
				<input type="text" id="qq" name="qq" value="<%=qq%>" <%=edit%> style="WIDTH: 300px;TEXT-ALIGN: left;TEXT-VALIGN:middle">
			</td>
		</tr>
		<tr>
			<th align="right">发布时间：</th>
			<td>
				<input type="hidden" id="post_time" name="post_time" value="<%=post_time%>"><%=post_time%>
			</td>
		</tr>
		<tr>
			<th align="right">状态：</th>
			<td>
				<%=AdminLib.getKeyValue("0,未发布|1,已发布",state)%>
			</td>
		</tr>
		<tr>
			<th align="right">添加时间：</th>
			<td>
				<input type="hidden" id="add_time" name="add_time" value="<%=add_time%>"><%=add_time%>
			</td>
		</tr>
		<tr>
			<th align="right">添加用户：</th>
			<td>
				<input type="hidden" id="add_user" name="add_user" value="<%=add_user%>"><%=add_user%>
			</td>
		</tr>
		<tr>
			<td width="10%"></td>
			<td width="40%"></td>
		</tr>
	
		
		<tr style="display:none">
			<input type="hidden" id="id" name="id" value="<%=id%>">
			<input type="hidden" id="state" name="state" value="<%=state%>">
			<!--隐藏(hidden)-->
			<input type="hidden" id="action" name="action" value="">
			<input type=hidden id="reload" checked name="reload" value='<%=SCRIPT_NAME+"?page=Form&method=edit"%>' >
		</tr>
	      
		<tr>
			<script>
				//操作						
				function toEdit()
				{	
					document.getElementById("action").value="edit";								
					document.getElementById("reload").value='<%=SCRIPT_NAME+"?page=Form&method="+method+"&d={$id}"%>'
				}
			</script>
			<!--按钮-->
			<td colspan="43" align="center">
				<input type="submit" name="edit" class="ButtonCss" value="保存" title="保存操作" onclick="return toEdit();">
				<input type="button" class="ButtonCss" onClick="javscript:window.location.href='<%=SCRIPT_NAME+"?page=List&method="+method%>';" value="返 回" />
			</td>
		</tr>
	</tbody>
</table>
</form>
<%}%>

</body>
</html>